<?php
	final class xd{
		public static function run(){
			self::setConst();
			self::createDir();
			self::loadSys();
			self::createApp();
			application::run();
		}
		private static function setConst(){
			define("PATH_ROOT",dirname($_SERVER['SCRIPT_FILENAME']));
			define("PATH_XD",PATH_ROOT.'/xd');
			define("PATH_APP",PATH_ROOT.'/'.APP_NAME);
		}
		private static function createDir(){
			$dirs=array(
				PATH_ROOT.'/config',
				PATH_ROOT.'/temp',
				PATH_ROOT.'/source',
				PATH_ROOT.'/upload',
				);
			foreach($dirs as $v){
				if(is_dir($v)) continue;
				mkdir($v,0777);
			}
		}
		private static function loadSys(){
			$sysFiles=array(
				PATH_XD.'/boot/functions.php',
				);
			foreach($sysFiles as $v){
				if(!is_file($v)) continue;
				include $v;
			}
		}
		private static function createApp(){
			$app=array(
				PATH_APP."/config",
				PATH_APP."/template",
				PATH_APP."/source",
				PATH_APP."/control",
				);
			foreach($app as $f){
				if(is_dir($f)) continue;
				mkdir($f,0777,true);
			}
		}
	}
	xd::run();
?>